package com.zjitc.controller.manage;/**
 * Create by IntelliJ IDEA
 *
 * @author: MaoYongQi
 * @date-Time: 2018/4/2 11:20
 * @description:
 */

import com.zjitc.common.ServerResponse;
import com.zjitc.model.User;
import com.zjitc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * Create by IntelliJ IDEA
 * @author: MaoYongQi
 * @date-Time: 2018/4/2 11:20
 * @description:
 */
@Controller
@RequestMapping("/manage/user")
public class UserManageController {

    @Autowired
    private UserService service;

    @RequestMapping("/login")
    @ResponseBody
    public ServerResponse<User> backlogin(String username,String password,HttpSession session){
        ServerResponse<User> response = service.backLogin(username,password,session);
        return response;
    }

    @RequestMapping("/list")
    @ResponseBody
    public ServerResponse<User> backlist(
            @RequestParam(value = "pageSize",required = false,defaultValue = "10")Integer pageSize,
            @RequestParam(value = "pageNum",required = false,defaultValue = "1")Integer pageNum,
            HttpSession session
    ){
        ServerResponse<User> response = service.list(pageNum,pageSize,session);
        return response;
    }
}
